package com.dragon.mmochat.message;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.model.role.MmochatFriend;
import com.dragon.mmochat.model.role.MmochatPlayer;
import com.skymobi.buffer.SkymobiBuffer;
import com.skymobi.message.SkymobiProtocolMessage;

public class Mmochat_10_11S extends SkymobiProtocolMessage {
	private MmochatFriend friend = null;
	MmochatPlayer me;

	public Mmochat_10_11S() {
		setMsgCode(MmochatConstant.MSGCODE_MMOCHAT_S_10_11);
	}

	@Override
	protected void encodeBody(SkymobiBuffer out) {
		if (friend == null){
			return;
		}
		out.putInt(friend.getRoleId());
		out.putInt(friend.getFriendListPrority());
		out.putUnsignedShort(friend.getBmpId());
		if (friend.isVip()) {
			out.put((byte) 1);
		} else {
			out.put((byte) 0);
		}
		out.put((byte) friend.getFriendState(me));
		out.putPrefixedString(friend.getName(), 1);
	}

	public void setFriend(MmochatFriend friend) {
		this.friend = friend;
	}

	public void setMe(MmochatPlayer me) {
		this.me = me;
	}

}
